<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="chrome=1;IE=edge">
    <meta name="viewport" content="user-scalable=no">
    <!-- vue -->
    <script src="/examples/js/vue.min.js"></script>
    <!-- 示例演示-公共样式 -->
    <link rel="stylesheet" href="/examples/css/railView.css" type="text/css" />
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <!-- RailUnit 样式 -->
    <link rel="stylesheet" href="/RailUnit/RailUnit.umd.css" type="text/css">
    <!-- RailUnit 插件 -->
    <script type="text/javascript" src="/RailUnit/RailUnit.umd.js" charset="utf-8"></script>
    <style>
        input[type="color"] {
            position: relative;
            top: -11px;
            height: 0;
            width: 0;
            border: 0;
            background: 0;
        }
        input[type="color"]:after {
            content: '设置高亮颜色';
            position: absolute;
            top: 15px;
            background: rgba(34, 45, 50, 0.7);
            display: flex;
            justify-content: space-around;
            align-items: center;
            line-height: 35px;
            border-radius: 3px;
            color: #FFFFFF;
            width: 100px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="app">
        <div id="buttom-container">
            <input type="color" name="" value="#e6e6e6" id="color" @input="handleInput">
        </div>
        <div id="viewer" style="width:100%;height:100%;position:relative;float:left"></div>
    </div>
    <script id="viewerStartup" type="module">
        const vm = new Vue({
            el: '#app',
            data: {
                bimViewer: null,
            },
            mounted () {
                this.bimViewerFn()
            },
            methods: {
                bimViewerFn() {
                    this.bimViewer = new MyViewer({
                        serverUrl: '/RailUnit/',
                        containerElement: document.getElementById('viewer'), // WebGL canvas
                    })
                    this.bimViewer.loadModel2('jianzhu', () => {})
                },
                setHighlightColor(hex) {
                    const red = Number('0x' + hex.substring(1, 3));
                    const green = Number('0x' + hex.substring(3, 5));
                    const blue = Number('0x' + hex.substring(5, 7));
                    this.bimViewer.setSolidsHighlightColor([red, green, blue], 1, true)
                },
                handleInput () {
                    const colorObj = document.getElementById('color');
                    console.log(colorObj.value, 'handleInput----colorObj');
                    this.setHighlightColor(colorObj.value);
                }
            }
        })
    </script>
</body>
</html>
